package com.atguigu.gmall.seckill.config;


import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author jzq
 * @create 2021-07-16 19:22
 */
@Configuration
public class SeckillRabbitConfig {
    //创建秒杀交换机
    @Bean("seckillExchange")
    public Exchange seckillExchange(){
        return ExchangeBuilder.topicExchange("seckill_exchange").build();
    }
    /**
     *创建秒杀队列
     */
    @Bean("seckillQueue")
    public Queue seckillQueue(){
        return QueueBuilder.durable("seckill_queue").build();
    }
    /**
     * 创建绑定
     */
    @Bean
    public Binding seckillBinding(@Qualifier("seckillExchange") Exchange exchange,
                                  @Qualifier("seckillQueue") Queue seckillQueue){
        return BindingBuilder.bind(seckillQueue).to(exchange).with("seckill.#").noargs();

    }

}
